package com.shop2cn.iapi.sqoptrade.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

import com.ymttest.business.service.shenqi.bean.SqStockService;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.shenqisettlement.parameter.bean.AgentProductBean;
import com.shop2cn.iapi.sqoptrade.parameter.enums.PayStatusEnum;
import com.shop2cn.iapi.sqoptrade.parameter.enums.PayTypeEnum;
import com.shop2cn.iapi.sqoptrade.parameter.req.PayReq;
import com.shop2cn.iapi.sqoptrade.parameter.req.PlaceOrderReq;
import com.shop2cn.iapi.sqoptrade.parameter.utill.Utils;
import com.shop2cn.iapi.sqoptrade.parameter.vo.OrderVo;
import com.shop2cn.iapi.sqoptrade.resp.Order;
import com.shop2cn.iapi.sqoptrade.resp.TradingServiceResp;
import com.shop2cn.iapi.sqoptrade.service.PayReqCall;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.iapi.productmanager.service.AddSellerProductCall;
import com.ymatou.iapi.productmanager.service.SaveCatalogPackageListCall;
import com.ymatou.iapi.synctrade.service.TradingSyncService;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.business.service.ProductManagerCallServiceV2;
import com.ymttest.business.service.SQPayGateWayCallService;
import com.ymttest.business.service.shenqi.AccountCallServiceV2;
import com.ymttest.business.service.shenqi.CounterService;
import com.ymttest.business.service.shenqi.DGSQBaseService;
import com.ymttest.business.service.shenqi.DGSQBuildProxyChainCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.business.service.shenqi.RefundService;
import com.ymttest.business.service.shenqi.SqPretradeService;
import com.ymttest.business.service.shenqi.SqTradingBookingOrderCallService;
import com.ymttest.business.service.shenqi.SqTradingCallService;
import com.ymttest.business.service.shenqi.bean.ShenqiUserSet;
import com.ymttest.database.model.YmtCatalogsI;
import com.ymttest.database.sharding.db.sharding.model.OrderPo;
import com.ymttest.database.sharding.db.sharding.model.OrderStatusLogPo;
import com.ymttest.database.sharding.db.sharding.model.PaymentPo;
import com.ymttest.database.sharding.db.sharding.model.UserRefundFundDetailPo;
import com.ymttest.database.sharding.db.sqlwapper.OrderShardingWapper;
import com.ymttest.database.sqlwapper.AccountWapper;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.MapUtil;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.constant.ECode;

/**
 * 支付接口 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_DGSQOrderPay {

	private static PayReq payReq;
	private static PayReqCall payReqCall;

	private static OrderShardingWapper database = new OrderShardingWapper();

	// 代购神器测试固定汇率
	private String settleRate = SQPayGateWayCallService.HKExchangeRate;

	private static long autotest_goodsOwnerId = ShenqiUserSet.autotest_goodsOwnerId;
	private static long yabandGoodsOwnerId = ShenqiUserSet.yabandGoodsOwnerId;
	private static long chainStoreGoodsOwnerId = ShenqiUserSet.chainStoreGoodsOwnerId;
	private static long virtualCoinGoodsOwnerId = ShenqiUserSet.virtualCoinGoodsOwnerId;
	private static long macaoCDFGoodsOwnerId = ShenqiUserSet.macaoCDFGoodsOwnerId;
	private static long platformSupplierGoodsOwnerId = ShenqiUserSet.platformSupplierGoodsOwnerId;
	private static long multiCDFCodeGoodsOwnerId = ShenqiUserSet.multiCDFCodeGoodsOwnerId;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("新增支付接口——神器");

		// 防止商家余额不足，导致退款失败
		String accountid1;
		try {
			accountid1 = AccountCallServiceV2.getAccountId(24635724);
			AccountCallServiceV2.resetAccount(accountid1, new BigDecimal(
					9000000), new BigDecimal(0));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Before
	public void caseUp() {
		payReq = new PayReq();
		payReqCall = new PayReqCall();
		settleRate = SQPayGateWayCallService.HKExchangeRate;
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(payReqCall.getOpurl() + "Sq");

		database.activeDeadCommunicationsLink(database);
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@SuppressWarnings("deprecation")
	public static String getPackageCatalogId() throws Exception {

		SaveCatalogPackageListCall saveCatalogPackageListCall = new SaveCatalogPackageListCall();
		int packageId1 = saveCatalogPackageListCall
				.callAndGetReturnData(
						MapUtil.hashMap(
								"ProductPackageList[0]->SubCatalogName",
								"测试组合001测试组合001",
								"ProductPackageList[0]->Price", 20,
								"ProductPackageList[0]->Num", 30,
								"ProductPackageList[0]->Sku", "test",
								"ProductPackageList[0]->ProductCode",
								"procodetest")).getJSONObject("Data")
				.getJSONArray("SubCatalogIdList").getInt(0);

		int packageId2 = saveCatalogPackageListCall
				.callAndGetReturnData(
						MapUtil.hashMap(
								"ProductPackageList[0]->SubCatalogName",
								"测试组合002测试组合001")).getJSONObject("Data")
				.getJSONArray("SubCatalogIdList").getInt(0);

		int packageId3 = saveCatalogPackageListCall
				.callAndGetReturnData(
						MapUtil.hashMap(
								"ProductPackageList[0]->SubCatalogName",
								"测试组合003测试组合001")).getJSONObject("Data")
				.getJSONArray("SubCatalogIdList").getInt(0);

		int packageId4 = saveCatalogPackageListCall
				.callAndGetReturnData(
						MapUtil.hashMap(
								"ProductPackageList[0]->SubCatalogName",
								"测试组合004测试组合001")).getJSONObject("Data")
				.getJSONArray("SubCatalogIdList").getInt(0);

		/*
		 * AddSellerProductRequest addProdReq =
		 * AddProductCallService.getAddSellerProductRequestFromFile("多规格带SPU",
		 * MapUtil.hashMap("sellerId",sellerId,"sellerName",sellerName));
		 */

		AddSellerProductRequest addProdReq = ProductManagerCallServiceV2
				.initAddSellerProductRequest(288484);
		// 带上套装
		addProdReq.getProduct().getCatalogList().get(0)
				.setSubCatalogIdList((Arrays.asList(packageId1, packageId2)));
		addProdReq.getProduct().getCatalogList().get(0).setPackage(true);

		addProdReq.getProduct().getCatalogList().get(1)
				.setSubCatalogIdList((Arrays.asList(packageId3, packageId4)));
		addProdReq.getProduct().getCatalogList().get(1).setPackage(true);

		AddSellerProductCall addSellerProductCall = new AddSellerProductCall();
		addSellerProductCall.setData(addProdReq);
		addSellerProductCall.callService();

		// 获取商品ID
		String productId = ProductManagerCallServiceV2
				.addNewProduct(addProdReq).get("Data").getAsJsonObject()
				.get("ProductId").getAsString();
		// 获取规格ID
		List<String> catalogs = new YmtCatalogsIWapper()
				.selectCatalogsByProductId(productId).stream()
				.map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());

		return catalogs.get(0);
	}

	private void verifyDb(long paymentId, BigDecimal useAccountAmount,
						  List<Order> orderList, BigDecimal cmbDiscountAmount) throws Exception {

		this.verifyDb(paymentId, useAccountAmount, orderList, cmbDiscountAmount, false);
	}

	/**
	 * 支付完成后（包括第三方支付回调交易完成）,校验订单数据
	 * 
	 * @param paymentId
	 * @param useAccountAmount
	 * @param orderList
	 * @param cmbDiscountAmount
	 * @param isVerificationPreStock 预售库存是否添加库存核销
	 * @throws Exception
	 */
	private void verifyDb(long paymentId, BigDecimal useAccountAmount,
			List<Order> orderList, BigDecimal cmbDiscountAmount, boolean isVerificationPreStock) throws Exception {

		// 用户id
		long userId = 0;

		userId = payReq.getUserId();

		BigDecimal payDeductAmount = BigDecimal.ZERO;
		BigDecimal orderDiscount = BigDecimal.ZERO;
		BigDecimal realNeedPayAmount = BigDecimal.ZERO;
		BigDecimal freight = BigDecimal.ZERO;
		BigDecimal totalYmtCouponAmount = BigDecimal.ZERO;
		BigDecimal totalSellerCouponAmount = BigDecimal.ZERO;
		BigDecimal needPayAmount = BigDecimal.ZERO;
		BigDecimal totalTaxFee = BigDecimal.ZERO;
		BigDecimal totalServiceAomunt = BigDecimal.ZERO;
		BigDecimal totalIntegralDeductionAmount = BigDecimal.ZERO;

		BigDecimal shenqiPaymentRmbAmount = payReq.getPayAmount();
		BigDecimal totalOrderShenqiPaymentRmbAmount = BigDecimal.ZERO;

		String bidCurrency = null;
		String payment_payCurrency = null;
		Integer customSettlementCurrencyType = null;
		Integer payChannelType = null;

		BigDecimal[] realNeedPayAmountList = new BigDecimal[orderList.size()];
		BigDecimal[] orderDiscountList = new BigDecimal[orderList.size()];
		
		Boolean isBalance = false;

		totalYmtCouponAmount = orderList.stream()
				.map(o -> o.getOrderPo().getYmtCouponAmount())
				.reduce(BigDecimal.ZERO, BigDecimal::add);
		totalSellerCouponAmount = orderList.stream()
				.map(o -> o.getOrderPo().getSellerCouponAmount())
				.reduce(BigDecimal.ZERO, BigDecimal::add);
		totalTaxFee = orderList.stream().map(o -> o.getOrderPo().getTaxFee())
				.reduce(BigDecimal.ZERO, BigDecimal::add);
		totalServiceAomunt = payReq.getPayType().equalsIgnoreCase("200") ? BigDecimal.ZERO
				: orderList.stream()
						.map(o -> o.getOrderPo().getServiceAmount())
						.reduce(BigDecimal.ZERO, BigDecimal::add);
		totalIntegralDeductionAmount = orderList.stream()
				.map(o -> o.getOrderPo().getIntegralDeductionAmount())
				.reduce(BigDecimal.ZERO, BigDecimal::add);

		if (payReq.getTradeType() == 1) {

			for (int i = 0; i < orderList.size(); i++) {

				database.clearCache();

				OrderPo orderPo = database.selectOrderbyOrderId(orderList
						.get(i).getOrderId());
				orderDiscount = orderDiscount.add(orderPo.getOrderDiscount());
				bidCurrency = orderPo.getCurrency();
				freight = freight.add(orderPo.getFreight());
				realNeedPayAmountList[i] = orderPo.getPayableAmount();
				orderDiscountList[i] = orderPo.getOrderDiscount();

				realNeedPayAmount = realNeedPayAmount.add(orderPo
						.getPayableAmount());

				customSettlementCurrencyType = orderPo
						.getCustomSettlementCurrencyType();
				payChannelType = orderPo.getPayChannelType();
			}

			// 该交易需要支付的总金额
			needPayAmount = orderList.stream()
					.map(o -> o.getOrderPo().getTotalPrice())
					.reduce(BigDecimal.ZERO, BigDecimal::add)
					.subtract(payDeductAmount).add(orderDiscount).add(freight)
					.add(totalTaxFee).add(totalServiceAomunt)
					.subtract(totalSellerCouponAmount)
					.subtract(totalYmtCouponAmount).subtract(totalIntegralDeductionAmount);
		} else {

			for (int i = 0; i < orderList.size(); i++) {

				database.clearCache();

				OrderPo orderPo = database.selectOrderbyOrderId(orderList
						.get(i).getOrderId());
				orderDiscount = orderDiscount.add(orderPo.getOrderDiscount());
				bidCurrency = orderPo.getCurrency();
				freight = freight.add(orderPo.getFreight());
				realNeedPayAmountList[i] = orderPo.getPayableAmount();
				orderDiscountList[i] = orderPo.getOrderDiscount();

				realNeedPayAmount = realNeedPayAmount.add(orderPo
						.getPayableAmount());

				customSettlementCurrencyType = orderPo
						.getCustomSettlementCurrencyType();
				payChannelType = orderPo.getPayChannelType();
			}

			// 该交易需要支付的总金额，定金不需要运费
			needPayAmount = orderList.stream()
					.map(o -> o.getOrderPo().getEarnestAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add)
					.subtract(payDeductAmount).add(orderDiscount)
					.add(totalTaxFee).subtract(totalSellerCouponAmount)
					.subtract(totalYmtCouponAmount);
		}

		if (payReq.getDiscountAfterPay())
			needPayAmount = needPayAmount.subtract(orderDiscount);

		// 用户支付的余额
		useAccountAmount = Utils.zeroIfNull(useAccountAmount);
		
		if (useAccountAmount.compareTo(BigDecimal.ZERO) > 0)
			isBalance = true;

		// 支付类型
		PayTypeEnum type = isBalance ? PayTypeEnum.FULL_BALANCE
				: PayTypeEnum.FULL_THIRD_PARTY;

		// 支付表(payment)
		PaymentPo paymentPo = database.selectPaymentById(paymentId);

		PaymentPo expectedPayment = new PaymentPo();

		expectedPayment.setUserId(userId);
		expectedPayment.setPaymentId(paymentId);
		expectedPayment.setAccountAmount(useAccountAmount);
		expectedPayment.setPayableAmount(needPayAmount);
		expectedPayment.setThirdpartyAmount(needPayAmount
				.subtract(useAccountAmount));

		expectedPayment.setTradeType(payReq.getTradeType());
		expectedPayment.setPayStatus(PayStatusEnum.MINUS_BALANCE_SUCCESS
				.getCode());
		expectedPayment.setPayType(type.getCode());

		expectedPayment.setThirdpartyDiscount(cmbDiscountAmount);
		expectedPayment.setPayDeductAmount(payDeductAmount);

		expectedPayment.setRealPaidAmount(realNeedPayAmount);
		expectedPayment.setRetryTimes(0);

		Order orderPo = orderList
				.stream()
				.max((o1, o2) -> o1.getOrderPayableAmount().compareTo(
						o2.getOrderPayableAmount())).get();
		
		long goodsOwnerId = orderPo.getOrderPo().getGoodsOwnerId();

		Boolean mchSupportHpCNY = GodmchManageCallService
				.getMchSupportHpCNY(goodsOwnerId);

		// 如果订单上面的currency为null，则payment上面的payCurrency为CNY
		if (null == bidCurrency
				|| SqTradingCallService.isShengPay(payReq.getPayType())
				|| !mchSupportHpCNY
				|| Utils.zeroIfNull(customSettlementCurrencyType) == 1)
			payment_payCurrency = "CNY";
		else
			payment_payCurrency = bidCurrency;

		expectedPayment.setPayCurrency(payment_payCurrency);

		String settleCurrency = GodmchManageCallService.getMchInfoBySellerId(
				orderPo.getOrderPo().getGoodsOwnerId()).getCurrency();

		if (settleCurrency.equalsIgnoreCase("KRW"))
			settleCurrency = "USD";

		boolean isCmbPay = payReq.getPayType() == "8000" || payReq.getPayType() == "8100";

		if (payReq.getPayType() == "6000" || payReq.getPayType() == "6001"
				|| payReq.getPayType() == "6002"
				|| payReq.getPayType() == "6003"
				|| payReq.getPayType() == "6006"
				|| payReq.getPayType() == "6207"
				|| payReq.getPayType() == "6401") {

			expectedPayment.setAppName(payReq.getShenqiMpId());

			if (payReq.getPayType() == "6002" || payReq.getPayType() == "6003"
					|| payReq.getPayType() == "6001")
				expectedPayment.setPaidMerchantNum("WC5d8d865dd40fc");
			else if (payReq.getPayType() == "6000"
					|| payReq.getPayType() == "6006")
				expectedPayment.setPaidMerchantNum("WC5c78d78282173");
			else if (payReq.getPayType() == "6401")
				expectedPayment.setPaidMerchantNum("WC5eb9016c6913e");
			else
				expectedPayment.setPaidMerchantNum("1900087246");

			if (Utils.zeroIfNull(customSettlementCurrencyType) == 1
					&& !payment_payCurrency.equalsIgnoreCase("CNY")) {

				BigDecimal exchageRate = DGSQBaseService.getCurrencyConfig(
						Utils.nullIsCNY(bidCurrency)).getExchangeRmbRate();

				expectedPayment.setExchangeRate(shenqiPaymentRmbAmount.divide(
						expectedPayment.getPayableAmount(), 5,
						BigDecimal.ROUND_DOWN).toString());
				settleRate = "1";

				BigDecimal foreignAmount = needPayAmount.multiply(exchageRate)
						.setScale(2, BigDecimal.ROUND_DOWN);
				expectedPayment.setForeignAmount(foreignAmount);

				BigDecimal realForeignAmount = SqTradingCallService
						.calRealForeignAmount(
								expectedPayment.getRealPaidAmount(),
								expectedPayment.getPayableAmount(),
								expectedPayment.getForeignAmount());

				expectedPayment.setSettleCurrency(settleCurrency);
				expectedPayment.setSettleRate(settleRate);
				expectedPayment.setRealForeignAmount(realForeignAmount);
				expectedPayment.setShenqiPaymentRmbAmount(realForeignAmount);
				expectedPayment.setPayCurrency(Utils
						.nullIsCNY(payment_payCurrency));

				expectedPayment.setRealSubmitRmbAmount(realForeignAmount);

				totalOrderShenqiPaymentRmbAmount = expectedPayment
						.getShenqiPaymentRmbAmount();

			} else if (!Utils.nullIsCNY(bidCurrency).equalsIgnoreCase("CNY")
					&& Utils.zeroIfNull(customSettlementCurrencyType) == 1
					&& payment_payCurrency.equalsIgnoreCase("CNY")) {

				BigDecimal exchageRate = DGSQBaseService.getCurrencyConfig(
						Utils.nullIsCNY(bidCurrency)).getExchangeRmbRate();

				expectedPayment.setExchangeRate(shenqiPaymentRmbAmount.divide(
						expectedPayment.getPayableAmount(), 5,
						BigDecimal.ROUND_DOWN).toString());

				expectedPayment.setForeignAmount(expectedPayment
						.getPayableAmount());

				BigDecimal realForeignAmount = SqTradingCallService
						.calRealForeignAmount(
								expectedPayment.getRealPaidAmount(),
								expectedPayment.getPayableAmount(),
								expectedPayment.getForeignAmount());

				expectedPayment.setSettleCurrency(settleCurrency);
				expectedPayment.setSettleRate(exchageRate.setScale(5,
						BigDecimal.ROUND_DOWN).toPlainString());
				expectedPayment.setRealForeignAmount(realForeignAmount);
				expectedPayment
						.setShenqiPaymentRmbAmount(shenqiPaymentRmbAmount);
				expectedPayment.setPayCurrency(Utils
						.nullIsCNY(payment_payCurrency));

				expectedPayment.setRealSubmitRmbAmount(shenqiPaymentRmbAmount);

				totalOrderShenqiPaymentRmbAmount = expectedPayment
						.getShenqiPaymentRmbAmount();

			} else if (!payment_payCurrency.equalsIgnoreCase("CNY")
					&& !payment_payCurrency.equalsIgnoreCase(settleCurrency)) {

				BigDecimal exchageRate = DGSQBaseService.getCurrencyConfig(
						Utils.nullIsCNY(bidCurrency)).getExchangeRmbRate();
				String settleRate = DGSQBaseService
						.getCurrencyConfig(settleCurrency).getExchangeRmbRate()
						.setScale(5, BigDecimal.ROUND_DOWN).toPlainString();

				BigDecimal foreignAmount = needPayAmount.multiply(exchageRate)
						.divide(new BigDecimal(settleRate), 2,
								BigDecimal.ROUND_DOWN);
				BigDecimal rmbAmount = needPayAmount.multiply(exchageRate)
						.setScale(2, BigDecimal.ROUND_HALF_DOWN);

				expectedPayment.setForeignAmount(foreignAmount);

				BigDecimal realForeignAmount = SqTradingCallService
						.calRealForeignAmount(
								expectedPayment.getRealPaidAmount(),
								expectedPayment.getPayableAmount(),
								expectedPayment.getForeignAmount());

				expectedPayment.setExchangeRate(shenqiPaymentRmbAmount.divide(
						expectedPayment.getPayableAmount(), 5,
						BigDecimal.ROUND_DOWN).toString());
				expectedPayment.setSettleCurrency(settleCurrency);

				expectedPayment.setSettleRate(settleRate);
				expectedPayment.setRealForeignAmount(realForeignAmount);
				expectedPayment.setShenqiPaymentRmbAmount(rmbAmount);
				expectedPayment.setPayCurrency(Utils
						.nullIsCNY(payment_payCurrency));

				expectedPayment.setRealSubmitRmbAmount(rmbAmount);

				totalOrderShenqiPaymentRmbAmount = expectedPayment
						.getShenqiPaymentRmbAmount();

			} else if (Utils.nullIsCNY(bidCurrency).equalsIgnoreCase("CNY")
					&& !mchSupportHpCNY) {

				BigDecimal exchageRate = DGSQBaseService.getCurrencyConfig(
						Utils.nullIsCNY(settleCurrency)).getExchangeRmbRate();
				BigDecimal foreignAmount = expectedPayment
						.getPayableAmount()
						.multiply(
								BigDecimal.ONE.divide(exchageRate, 7,
										BigDecimal.ROUND_HALF_DOWN))
						.setScale(2, BigDecimal.ROUND_HALF_DOWN);

				expectedPayment.setExchangeRate(shenqiPaymentRmbAmount.divide(
						expectedPayment.getPayableAmount(), 5,
						BigDecimal.ROUND_HALF_DOWN).toString());

				expectedPayment.setForeignAmount(foreignAmount);

				BigDecimal realForeignAmount = SqTradingCallService
						.calRealForeignAmount(
								expectedPayment.getRealPaidAmount(),
								expectedPayment.getPayableAmount(),
								expectedPayment.getForeignAmount());

				expectedPayment.setSettleCurrency(settleCurrency);
				expectedPayment.setSettleRate("1");
				expectedPayment.setRealForeignAmount(realForeignAmount);
				expectedPayment
						.setShenqiPaymentRmbAmount(shenqiPaymentRmbAmount);
				expectedPayment.setPayCurrency(Utils.nullIsCNY(settleCurrency));

				expectedPayment.setRealSubmitForeignAmount(realForeignAmount);
				// expectedPayment.setRealSubmitRmbAmount(realForeignAmount);
				expectedPayment.setRmbVsRealSubmitForeignRate(BigDecimal.ONE
						.divide(exchageRate, 7, BigDecimal.ROUND_HALF_DOWN));

				// totalOrderShenqiPaymentRmbAmount =
				// expectedPayment.getRealPaidAmount();
				totalOrderShenqiPaymentRmbAmount = expectedPayment
						.getShenqiPaymentRmbAmount();
			} else if (!payment_payCurrency.equalsIgnoreCase("CNY")) {

				expectedPayment.setExchangeRate(shenqiPaymentRmbAmount.divide(
						expectedPayment.getPayableAmount(), 5,
						BigDecimal.ROUND_UP).toString());
				settleRate = "1";

				BigDecimal foreignAmount = needPayAmount;
				expectedPayment.setForeignAmount(foreignAmount);

				BigDecimal realForeignAmount = SqTradingCallService
						.calRealForeignAmount(
								expectedPayment.getRealPaidAmount(),
								expectedPayment.getPayableAmount(),
								expectedPayment.getForeignAmount());

				expectedPayment.setSettleCurrency(settleCurrency);
				expectedPayment.setSettleRate(settleRate);
				expectedPayment.setRealForeignAmount(realForeignAmount);
				expectedPayment
						.setShenqiPaymentRmbAmount(shenqiPaymentRmbAmount);
				expectedPayment.setPayCurrency(Utils
						.nullIsCNY(payment_payCurrency));

				totalOrderShenqiPaymentRmbAmount = expectedPayment
						.getShenqiPaymentRmbAmount();

			} else {

				expectedPayment.setExchangeRate(shenqiPaymentRmbAmount.divide(
						expectedPayment.getPayableAmount(), 5,
						BigDecimal.ROUND_DOWN).toString());

				expectedPayment.setForeignAmount(needPayAmount.divide(
						new BigDecimal(settleRate), 2, BigDecimal.ROUND_DOWN));
				BigDecimal realForeignAmount = SqTradingCallService
						.calRealForeignAmount(
								expectedPayment.getRealPaidAmount(),
								expectedPayment.getPayableAmount(),
								expectedPayment.getForeignAmount());

				expectedPayment.setSettleCurrency(settleCurrency);
				expectedPayment.setSettleRate(settleRate);
				expectedPayment.setRealForeignAmount(realForeignAmount);

				expectedPayment
						.setShenqiPaymentRmbAmount(payReq.getPayAmount());

				totalOrderShenqiPaymentRmbAmount = expectedPayment
						.getShenqiPaymentRmbAmount();
			}
		} else if (SqTradingCallService.isShengPay(payReq.getPayType())) {

			expectedPayment.setAppName(payReq.getShenqiMpId());
			expectedPayment.setPaidMerchantNum("30057909");

			// 渠道结算币种为人民币，标价币种为外币
			if ((null != customSettlementCurrencyType || Utils
					.zeroIfNull(payChannelType) == 2)
					&& !Utils.nullIsCNY(bidCurrency).equalsIgnoreCase("CNY")) {

				BigDecimal exchageRate = DGSQBaseService.getCurrencyConfig(
						Utils.nullIsCNY(bidCurrency)).getExchangeRmbRateForTe();

				BigDecimal foreignAmount = needPayAmount.multiply(exchageRate)
						.setScale(2, BigDecimal.ROUND_HALF_DOWN);
				expectedPayment.setForeignAmount(foreignAmount);

				BigDecimal realForeignAmount = SqTradingCallService
						.calRealForeignAmount(
								expectedPayment.getRealPaidAmount(),
								expectedPayment.getPayableAmount(),
								expectedPayment.getForeignAmount());

				expectedPayment.setExchangeRate(exchageRate.setScale(5,
						BigDecimal.ROUND_DOWN).toString());
				expectedPayment.setForeignAmount(foreignAmount);
				expectedPayment.setSettleCurrency("CNY");
				expectedPayment.setSettleRate("1");
				expectedPayment.setRealForeignAmount(realForeignAmount);
				expectedPayment
						.setShenqiPaymentRmbAmount(payReq.getPayAmount());
				expectedPayment.setPayCurrency(Utils
						.nullIsCNY(payment_payCurrency));

				expectedPayment.setRealSubmitRmbAmount(payReq.getPayAmount());
			} else {

				expectedPayment.setExchangeRate("1.00000");

				expectedPayment.setForeignAmount(needPayAmount);
				expectedPayment.setSettleCurrency("CNY");
				expectedPayment.setSettleRate("1");
				expectedPayment.setRealForeignAmount(needPayAmount);
				expectedPayment
						.setShenqiPaymentRmbAmount(payReq.getPayAmount());
			}

			totalOrderShenqiPaymentRmbAmount = expectedPayment
					.getShenqiPaymentRmbAmount();
		} else if (isBalance) {
			
			expectedPayment.setAppName(payReq.getShenqiMpId());
			expectedPayment.setExchangeRate("1.00000");
			expectedPayment
					.setShenqiPaymentRmbAmount(useAccountAmount);
			expectedPayment.setPayChannel("VirtualCurrencyPay");
			
			totalOrderShenqiPaymentRmbAmount = expectedPayment
					.getShenqiPaymentRmbAmount();
		} else if (payReq.getPayType() == "7200") {
			
			expectedPayment.setSettleRate("1");
			expectedPayment.setSettleCurrency("MOP");
			expectedPayment.setPaidMerchantNum("WC5c78d78282173");
			expectedPayment.setForeignAmount(needPayAmount);
			expectedPayment.setRealForeignAmount(needPayAmount);
			expectedPayment.setAppName("502665591");
		} else if (isCmbPay) {
			
			expectedPayment.setSettleRate("1");
			expectedPayment.setSettleCurrency("CNY");
			expectedPayment.setPaidMerchantNum("WC5c78d78282173");
			expectedPayment.setForeignAmount(needPayAmount);
			expectedPayment.setRealForeignAmount(needPayAmount);
//			expectedPayment.setAppName("500024716");
			expectedPayment.setAppName("510019073");
		}

		expectedPayment.setGatewayPayType(payReq.getPayType());
		
		expectedPayment.setHelpPayIdcardId(payReq.getHelpPayIdcardId());
		expectedPayment.setHelpPayUserId(payReq.getHelpPayUserId());

		// 如果是买家同意线下支付的订单，不需要验证paymentDb
		if (null == payReq.getPayType()
				|| !payReq.getPayType().equalsIgnoreCase("200"))
			verifyPaymentDb(expectedPayment, paymentPo);

		BigDecimal[] weights = new BigDecimal[orderList.size()];

		for (int i = 0; i < orderList.size(); i++) {
			weights[i] = realNeedPayAmountList[i];
		}

		BigDecimal thirdPaid[];

		if (useAccountAmount == BigDecimal.ZERO
				&& cmbDiscountAmount == BigDecimal.ZERO
				&& payDeductAmount == BigDecimal.ZERO)
			thirdPaid = weights;
		else
			thirdPaid = Utils.apportionByWeights3(
					needPayAmount.subtract(useAccountAmount).subtract(
							cmbDiscountAmount), weights, null);

		BigDecimal thirdDiscount[] = Utils.apportionByWeights3(
				cmbDiscountAmount, weights, null);

		for (int i = 0; i < orderList.size(); i++) {

			// 订单号
			long orderId = orderList.get(i).getOrderId();

			// 订单表(order)
			OrderPo ymtOrder = database.selectOrderbyOrderId(orderId);

			// 订单应付金额
			BigDecimal orderPayAmount = ymtOrder.getPayableAmount();

			Logger.comment("验证订单号:" + orderId);
			Logger.comment("验证订单表(order)表");

			if (isVerificationPreStock) {

				Logger.comment("预售库存订单，添加库存后，验证订单核销状态");

				Logger.verifyEquals(false, ymtOrder.getWaitInStock(), "验证订单表WaitInStock");
				Logger.verifyEquals(true, ymtOrder.getInStockTime() != null,
						"验证订单表InStockTime");
			}

			if (!payReq.getPayType().equalsIgnoreCase("200")) {
				
				if (payReq.getTradeType() == 2
						&& ymtOrder.getEarnestPaymentId() != null) {

					Logger.verifyEquals(true, ymtOrder.getCanConfirm(),
							"验证数据库CanConfirm");
					Logger.verifyEquals(1, ymtOrder.getOrderStatus(),
							"验证orderStatus");
					
					Logger.verifyEquals(paymentId, ymtOrder.getEarnestPaymentId(),
							"验证数据库PaymentId");
				} else {

					if (goodsOwnerId == autotest_goodsOwnerId) {

						Logger.verifyEquals(
								true,
								ymtOrder.getOrderStatus() == 2
										|| ymtOrder.getOrderStatus() == 17,
								"验证orderStatus");
					} else
						Logger.verifyEquals(2, ymtOrder.getOrderStatus(),
								"验证orderStatus");
					
					// 如果全款支付成功，退定金
					if (payReq.getTradeType() == 1
							&& ymtOrder.getEarnestPaymentId() != null) {
						
						UserRefundFundDetailPo expected = new UserRefundFundDetailPo();
						
						expected.setOrderId(orderId);
						expected.setPaymentId(ymtOrder.getEarnestPaymentId());
						expected.setBizType(5);
						expected.setMemo(null);
						
						expected.setAccountAmount(BigDecimal.ZERO);
						expected.setAccountRefundStatus(-1);
						expected.setThirdpartyAmount(ymtOrder.getEarnestAmount());
						expected.setThirdpartyRefundStatus(3);
						expected.setIntegralRefundStatus(-1);		
						expected.setIsShenqi(true);
						expected.setRefundIntegral(0L);

						UserRefundFundDetailPo actual = database
								.selectShenqiUserRefundFundDetailByBizno(String.valueOf(orderId));
						
						RefundService.verifyUserRefundFundDetailDb(expected, actual);
					}

					Logger.verifyEquals(false, ymtOrder.getCanConfirm(),
							"验证数据库CanConfirm");
					
					Logger.verifyEquals(paymentId, ymtOrder.getPaymentId(),
							"验证数据库PaymentId");
				}
				
				if (payReq.getHelpPayUserId() != null) {

					Logger.verifyEquals(payReq.getHelpPayUserId(),
							ymtOrder.getHelpPayUserId(), "验证数据库HelpPayUserId");
					Logger.verifyEquals(payReq.getHelpPayIdcardId(),
							ymtOrder.getPurchaserIdcardId(),
							"验证数据库PurchaserIdcardId");
				}
			} else {

				Logger.verifyEquals(1, ymtOrder.getOrderStatus(),
						"验证orderStatus");
				Logger.verifyEquals(null, ymtOrder.getPaymentId(),
						"验证数据库PaymentId");
			}
			
			if (needPayAmount.compareTo(realNeedPayAmount) != 0) {

				if (!payReq.getPayType().equalsIgnoreCase("200"))
					DataUtil.verifyDecimalEquals(thirdPaid[i],
							ymtOrder.getThirdpartyPaidAmount(),
							"验证数据库ThirdpartyPaidAmount");
				else
					DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
							ymtOrder.getThirdpartyPaidAmount(),
							"验证数据库ThirdpartyPaidAmount");

				DataUtil.verifyDecimalEquals(
						orderPayAmount.subtract(thirdPaid[i]).subtract(
								thirdDiscount[i]),
								ymtOrder.getAccountPaidAmount(),
						"验证数据库AccountPaidAmount");

				DataUtil.verifyDecimalEquals(needPayAmount.add(orderDiscount),
						realNeedPayAmount, "验证数据库realNeedPayAmount");
			} else {

				if (!payReq.getPayType().equalsIgnoreCase("200")) {

					if (payReq.getTradeType() == 1) {

						DataUtil.verifyDecimalEquals(thirdPaid[i],
								ymtOrder.getThirdpartyPaidAmount(),
								"验证数据库ThirdpartyPaidAmount");
					} else {

						DataUtil.verifyDecimalEquals(thirdPaid[i],
								ymtOrder.getEarnestThirdpartyPaidAmount(),
								"验证数据库ThirdpartyPaidAmount");
					}
				} else
					DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
							ymtOrder.getThirdpartyPaidAmount(),
							"验证数据库ThirdpartyPaidAmount");
			}

			BigDecimal[] result = Utils.apportionByWeights(
					totalOrderShenqiPaymentRmbAmount, realNeedPayAmountList);

			if (payReq.getTradeType() == 1)
				DataUtil.verifyDecimalEquals(result[i],
						ymtOrder.getShenqiPaymentRmbAmount(),
						"验证order表ShenqiPaymentRmbAmount");
			else
				DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
						ymtOrder.getShenqiPaymentRmbAmount(),
						"验证order表ShenqiPaymentRmbAmount");
			

			if (payReq.getPayType().equalsIgnoreCase("200"))
				Logger.verifyEquals(true, ymtOrder.getOfflinePayFlag(),
						"OfflinePayFlag");
			else {

				Logger.verifyEquals(false, ymtOrder.getOfflinePayFlag(),
						"OfflinePayFlag");

				if (orderDiscountList[i].compareTo(BigDecimal.ZERO) == -1
						&& payReq.getDiscountAfterPay())
					Logger.verifyEquals(
							ymtOrder
									.getShenqiPaymentRmbAmount()
									.divide(realNeedPayAmountList[i]
											.subtract(orderDiscountList[i]), 5,
											BigDecimal.ROUND_HALF_DOWN)
									.toPlainString(), ymtOrder
									.getExchangeRate(), "验证order表ExchangeRate");
				else {

					if (payReq.getTradeType() == 1)

						if(isCmbPay)
							Logger.verifyEquals(
									null,
									ymtOrder.getExchangeRate(),
									"验证order表ExchangeRate");
						else {

							// 中免澳门ExchangeRate为null
							if (ymtOrder.getGoodsOwnerId() == 502665591)
								Logger.verifyEquals(
										null,
										ymtOrder.getExchangeRate(),
										"验证order表ExchangeRate");
							else
								Logger.verifyEquals(
										Utils.zeroIfNull(
												ymtOrder.getShenqiPaymentRmbAmount())
												.divide(realNeedPayAmountList[i], 5,
														BigDecimal.ROUND_HALF_DOWN)
												.toPlainString(),
										ymtOrder.getExchangeRate(),
										"验证order表ExchangeRate");

						}
					else
						Logger.verifyEquals(null, ymtOrder.getExchangeRate(),
								"验证order表ExchangeRate");
				}
			}

			DataUtil.verifyDecimalEquals(thirdDiscount[i],
					ymtOrder.getThirdpartyDiscount(),
					"验证数据库ThirdpartyDiscount");

			// 只有线下支付才有值
			Logger.verifyEquals(payReq.getVoucherUrl(),
					ymtOrder.getVoucherOriginalUrl(), "校验支付凭证");

			if (null == payReq.getPayType()
					|| !payReq.getPayType().equalsIgnoreCase("200")) {

				// 订单主状态操作日志表(order_status_log)
				OrderStatusLogPo orderStatusLogPo = database
						.selectOrderStatusLogByOrderId(orderId);

				Logger.comment("验证订单主状态操作日志表(order_status_log)");
				
				if (payReq.getTradeType() == 1) {

					// autotest_goodsOwnerId设置了支付后自动接单
					if (goodsOwnerId == autotest_goodsOwnerId) {

						Logger.verifyEquals(
								true,
								orderStatusLogPo.getMemo().equalsIgnoreCase(
										"接单")
										|| orderStatusLogPo.getMemo()
												.equalsIgnoreCase("支付完成"),
								"验证数据库Memo");
						Logger.verifyEquals(
								true,
								orderStatusLogPo.getOrderStatus() == 2
										|| orderStatusLogPo.getOrderStatus() == 17,
								"验证数据库OrderStatus");
						Logger.verifyEquals(
								true,
								orderStatusLogPo.getOperator() == -1
										|| orderStatusLogPo.getOperator() == userId,
								"验证数据库Operator");
					} else {

						Logger.verifyEquals("支付完成", orderStatusLogPo.getMemo(),
								"验证数据库Memo");
						Logger.verifyEquals(2,
								orderStatusLogPo.getOrderStatus(),
								"验证数据库OrderStatus");
						Logger.verifyEquals(userId,
								orderStatusLogPo.getOperator(), "验证数据库Operator");
					}
				} else {

					Logger.verifyEquals("定金已付，待支付全款",
							orderStatusLogPo.getMemo(), "验证数据库Memo");
					Logger.verifyEquals(1, orderStatusLogPo.getOrderStatus(),
							"验证数据库OrderStatus");
					Logger.verifyEquals(userId, orderStatusLogPo.getOperator(),
							"验证数据库Operator");
				}

				Logger.verifyEquals(
						true,
						Utils.calcTimeSpanMin(orderStatusLogPo.getAddTime()) < 2,
						"验证数据库AddTime跟系统当前时间差为2分钟内");

				Logger.verifyEquals(orderId, orderStatusLogPo.getOrderId(),
						"验证数据库OrderId");
			}
		}
		
		if (!payReq.getPayType().equalsIgnoreCase("200")
				&& !payReq.getPayType().equalsIgnoreCase("7000")) {

			Logger.comment("校验资金流水");
			AccountWapper accountWapper = new AccountWapper();

			HashMap<String, Object> accountEntryMap = new HashMap<>();

			if (payReq.getTradeType() == 1)
				accountEntryMap.put("bizcode", "360001");
			else
				accountEntryMap.put("bizcode", "300038");

			accountEntryMap.put("userId", payReq.getUserId());
			accountEntryMap.put("originalNo", paymentPo.getPaymentId());
			accountEntryMap.put("accountType", 60);

			if (paymentPo.getPayCurrency().equalsIgnoreCase("CNY"))
				DataUtil.verifyDecimalEquals(
						payReq.getPayAmount().negate(),
						accountWapper.selectAccountEntryByMap(accountEntryMap)
								.stream()
								.map(accountEntry -> accountEntry.getAmount())
								.reduce(BigDecimal.ZERO, BigDecimal::add),
						"验证accountEntry日志记录");
			else
				DataUtil.verifyDecimalEquals(
						paymentPo.getRealForeignAmount().negate(),
						accountWapper.selectAccountEntryByMap(accountEntryMap)
								.stream()
								.map(accountEntry -> accountEntry.getAmount())
								.reduce(BigDecimal.ZERO, BigDecimal::add),
						"验证accountEntry日志记录");
		}
	}

	/**
	 * 支付表(payment)
	 * 
	 * @param expectedPayment
	 * @param actualPayment
	 */
	private void verifyPaymentDb(PaymentPo expectedPayment,
			PaymentPo actualPayment) {

		Logger.comment(String.format("验证支付表(payment) ,paymentId :%s",
				expectedPayment.getPaymentId()));

		DataUtil.verifyDecimalEquals(expectedPayment.getThirdpartyAmount(),
				actualPayment.getThirdpartyAmount(), "验证数据库ThirdpartyAmount");
		DataUtil.verifyDecimalEquals(expectedPayment.getRealPaidAmount(),
				actualPayment.getRealPaidAmount(), "验证数据库RealPaidAmount");
		/*
		 * Logger.verifyEquals(expectedPayment.getGatewayPaymentId(),
		 * actualPayment.getGatewayPaymentId(), "验证数据库GatewayPaymentId");
		 * 
		 * Logger.verifyEquals(expectedPayment.getThirdpartyPaymentId(),
		 * actualPayment.getThirdpartyPaymentId(), "验证数据库ThirdpartyPaymentId");
		 * Logger.verifyEquals(expectedPayment.getGatewayCallback(),
		 * actualPayment.getGatewayCallback(), "验证数据库GatewayCallback");
		 * 
		 * Logger.verifyEquals(expectedPayment.getGatewayCallbackTime(),
		 * actualPayment.getGatewayCallbackTime(), "验证数据库GatewayCallbackTime");
		 * 
		 * Logger.verifyEquals(expectedPayment.getPayChannel(),
		 * actualPayment.getPayChannel(), "验证数据库PayChannel");
		 */

		Logger.verifyEquals(expectedPayment.getTradeType(),
				actualPayment.getTradeType(), "验证数据库TradeType");
		Logger.verifyEquals(true,
				Utils.calcTimeSpanMin(actualPayment.getUpdateTime()) < 2,
				"验证数据库UpdateTime跟系统当前时间差为2分钟内");
		Logger.verifyEquals(true,
				Utils.calcTimeSpanMin(actualPayment.getAddTime()) < 2,
				"验证数据库AddTime跟系统当前时间差为2分钟内");

		DataUtil.verifyDecimalEquals(expectedPayment.getPayableAmount(),
				actualPayment.getPayableAmount(), "验证数据库PayableAmount");
		Logger.verifyEquals(expectedPayment.getPaymentId(),
				actualPayment.getPaymentId(), "验证数据库PaymentId");
		Logger.verifyEquals(expectedPayment.getUserId(),
				actualPayment.getUserId(), "验证数据库UserId");
		DataUtil.verifyDecimalEquals(expectedPayment.getThirdpartyDiscount(),
				actualPayment.getThirdpartyDiscount(),
				"验证数据库ThirdpartyDiscount");

		DataUtil.verifyDecimalEquals(expectedPayment.getPayDeductAmount(),
				actualPayment.getPayDeductAmount(), "验证数据库payDeductAmount");

		Logger.verifyEquals(expectedPayment.getPayStatus(),
				actualPayment.getPayStatus(), "验证数据库PayStatus");

		Logger.verifyEquals(expectedPayment.getRetryTimes(),
				actualPayment.getRetryTimes(), "验证数据库RetryTimes");

		DataUtil.verifyDecimalEquals(expectedPayment.getAccountAmount(),
				actualPayment.getAccountAmount(), "验证数据库AccountAmount");
		Logger.verifyEquals(expectedPayment.getPayType(),
				actualPayment.getPayType(), "验证数据库PayType");

		Logger.verifyEquals(expectedPayment.getMemo(), actualPayment.getMemo(),
				"验证数据库Memo");

		Logger.verifyEquals(expectedPayment.getSettleCurrency(),
				actualPayment.getSettleCurrency(), "验证数据库SettleCurrency");
		Logger.verifyEquals(expectedPayment.getSettleRate(),
				actualPayment.getSettleRate(), "验证数据库SettleRate");
		Logger.verifyEquals(expectedPayment.getForeignAmount(),
				actualPayment.getForeignAmount(), "验证数据库ForeignAmount");
		if (payReq.getPayType().equalsIgnoreCase("6000")
				|| payReq.getPayType().equalsIgnoreCase("6010")
				|| payReq.getPayType().equalsIgnoreCase("6011")
				|| payReq.getPayType().equalsIgnoreCase("6006")
				|| payReq.getPayType().equalsIgnoreCase("6001")
				|| payReq.getPayType().equalsIgnoreCase("6002")
				|| payReq.getPayType().equalsIgnoreCase("6003")
				|| payReq.getPayType().equalsIgnoreCase("6207")
				|| payReq.getPayType().equalsIgnoreCase("6401")
				|| payReq.getPayType().equalsIgnoreCase("7200")
				|| payReq.getPayType().equalsIgnoreCase("8000"))
			Logger.verifyEquals(
					Utils.zeroIfNull(expectedPayment.getRealForeignAmount())
							.setScale(2, BigDecimal.ROUND_HALF_DOWN),
					actualPayment.getRealForeignAmount(),
					"验证数据库RealForeignAmount");
		else
			Logger.verifyEquals(null, actualPayment.getRealForeignAmount(),
					"验证数据库RealForeignAmount");

		Logger.verifyEquals(expectedPayment.getPayCurrency(),
				actualPayment.getPayCurrency(), "验证数据库PayCurrency");
		Logger.verifyEquals(expectedPayment.getExchangeRate(),
				actualPayment.getExchangeRate(), "验证数据库ExchangeRate");
		DataUtil.verifyDecimalEquals(
				expectedPayment.getShenqiPaymentRmbAmount(),
				actualPayment.getShenqiPaymentRmbAmount(),
				"验证数据库ShenqiPaymentRmbAmount");
		Logger.verifyEquals(expectedPayment.getAppName(),
				actualPayment.getAppName(), "验证数据库appName");
		Logger.verifyEquals(expectedPayment.getGatewayPayType(),
				actualPayment.getGatewayPayType(), "验证数据库gatewayPayType");

		Logger.verifyEquals(expectedPayment.getPaidMerchantNum(),
				actualPayment.getPaidMerchantNum(), "验证数据库paidMerchantNum");

		Logger.verifyEquals(expectedPayment.getRealSubmitRmbAmount(),
				actualPayment.getRealSubmitRmbAmount(),
				"验证数据库realSubmitRmbAmount");

		Logger.verifyEquals(expectedPayment.getRealSubmitForeignAmount(),
				actualPayment.getRealSubmitForeignAmount(),
				"验证数据库realSubmitForeignAmount");
		Logger.verifyEquals(expectedPayment.getRmbVsRealSubmitForeignRate(),
				actualPayment.getRmbVsRealSubmitForeignRate(),
				"验证数据库rmbVsRealSubmitForeignRate");
		
		Logger.verifyEquals(expectedPayment.getHelpPayUserId(),
				actualPayment.getHelpPayUserId(), "验证数据库HelpPayUserId");
		Logger.verifyEquals(expectedPayment.getHelpPayIdcardId(),
				actualPayment.getHelpPayIdcardId(), "验证数据库HelpPayIdcardId");
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_001() {
		Logger.start(true, "代购神器下单并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_002() {
		Logger.start(true, "代购神器下单向上调价并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2(BigDecimal.TEN, productBean, 1);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_003() {
		Logger.start(true, "代购神器下单向下调价并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2(new BigDecimal("-10.00"), productBean, 1);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_004() {
		Logger.start(true, "代购神器下单并支付，第三方回调前向上调价，支付失败，支付余额不足，快速退款");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			BigDecimal freight = orderList.stream()
					.map(order -> order.getOrderPo().getFreight())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			Long userId = placeOrderResp.getUserId();
			long orderId = orderList.get(0).getOrderId();
			long sellerId = orderList.get(0).getSellerId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			SqTradingCallService.changeDiscount(orderId, sellerId,
					BigDecimal.TEN, freight);

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);
			database.clearCache();

			Logger.verifyEquals(1, database.selectOrderbyOrderId(orderId)
					.getOrderStatus(), "验证orderStatus");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_006() {
		Logger.start(true, "代购神器下单时上调价格，下单完成后向下调价，并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.TEN);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			BigDecimal freight = orderList.stream()
					.map(order -> order.getOrderPo().getFreight())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			Long userId = placeOrderResp.getUserId();
			long orderId = orderList.get(0).getOrderId();
			long sellerId = orderList.get(0).getSellerId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			SqTradingCallService.changeDiscount(orderId, sellerId,
					new BigDecimal("-10.00"), freight);

			TradingSyncService.getSyncResult(orderId);

			database.clearCache();
			totalPrice = database.selectOrderbyOrderId(orderId)
					.getPayableAmount();

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_007() {
		Logger.start(true, "代购神器直销商下单并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder1(productBean, productBean.getSellerId());

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_008() {
		Logger.start(true, "代购神器下单，货币为CNY");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, currency);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_009() {
		Logger.start(true, "代购神器下单，货币为USD");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false,
							true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, currency);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_010() {
		Logger.start(true, "代购神器下单向下调价并支付，币种为外币");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false,
							true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2(new BigDecimal("-10.00"), productBean,
							currency, 1);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_011() {
		Logger.start(true, "代购神器下单时上调价格，下单完成后向下调价，并支付，币种为外币");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false,
							true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2(BigDecimal.TEN, productBean, currency, 1);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			BigDecimal freight = orderList.stream()
					.map(order -> order.getOrderPo().getFreight())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			Long userId = placeOrderResp.getUserId();
			long orderId = orderList.get(0).getOrderId();
			long sellerId = orderList.get(0).getSellerId();

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = BigDecimal.ZERO;

			SqTradingCallService.changeDiscount(orderId, sellerId,
					new BigDecimal("-10.00"), freight);

			TradingSyncService.getSyncResult(orderId);

			database.clearCache();

			BigDecimal totalPrice = orderList
					.stream()
					.map(order -> database.selectOrderbyOrderId(
							order.getOrderId()).getPayableAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_012() {
		Logger.start(true, "代购神器下单，货币为KRW");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createKRProxychain(500072235, 1, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 500072235);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingId(placeOrderResp.getTradingId());
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId(orderList.get(0).getSellerId().toString());

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_013() {
		Logger.start(true, "代购神器下单，appName为wxsqbuyer，不发送独立小程序消息");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createKRProxychain(500072235, 1, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 500072235);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingId(placeOrderResp.getTradingId());
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_014() {
		Logger.start(true, "代购神器下单，不输入ShenqiMpId，支付报错");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createKRProxychain(500072235, 1, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 500072235);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId(null);

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.ERROR400, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("100", payReqCall.getBCode(), "验证bcode");
			Logger.verifyEquals("请传入应用名称", payReqCall.getMsg(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_015() {
		Logger.start(true, "代购神器下单，输入错误的ShenqiMpId，支付成功");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createKRProxychain(500072235, 1, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 500072235);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");
			BigDecimal useAccountAmount = BigDecimal.ZERO;
			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingId(placeOrderResp.getTradingId());
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("shenqiMpId22222");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_016() {
		Logger.start(true, "代购神器下单，包含税费，向下调价并支付，币种为外币");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false,
							true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2(new BigDecimal("-10.00"), productBean,
							currency, new BigDecimal("0.03"),
							autotest_goodsOwnerId, 1);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_017() {
		Logger.start(true, "代购神器下单，货币为USD，买家同意线下支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false,
							true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2(productBean, autotest_goodsOwnerId, currency,
							true);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("200");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");
			payReq.setVoucherUrl(TestDataManager.randomStr(8));

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(totalPrice.subtract(BigDecimal.ZERO));

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_018() {
		Logger.start(true, "已经同意线下支付的订单，再次进行线上支付，支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false,
							true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, currency, true);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			// 同意线下支付的订单
			SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "200");

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");
			payReq.setVoucherUrl("voucherUrl");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.FAILED201, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("105", payReqCall.getBCode(), "验证BCode");
			Logger.verifyEquals("订单已确认线下支付，无需再支付", payReqCall.getMsg(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_019() {
		Logger.start(true, "已经同意线下支付的订单，再次同意线下支付，支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false,
							true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, currency, true);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			// 同意线下支付的订单
			SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "200");

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("200");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");
			payReq.setVoucherUrl("voucherUrl");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.FAILED201, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("105", payReqCall.getBCode(), "验证BCode");
			Logger.verifyEquals("订单已确认线下支付，无需再确认", payReqCall.getMsg(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_020() {
		Logger.start(true, "代购神器下单，货币为USD，支持线下支付的订单进行线上支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder1(productBean, productBean.getSellerId(), true);
			String currency = productBean.getCurrency();

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_021() {
		Logger.start(true, "不支持线下支付的订单，同意线下支付,支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false,
							true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, currency, false);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			// 同意线下支付的订单
			SqTradingCallService.payOrder(userId,
					placeOrderResp.getTradingId(), "wxsqBuyer", "200");

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("200");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");
			payReq.setVoucherUrl("voucherUrl");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.FAILED201, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("105", payReqCall.getBCode(), "验证BCode");
			Logger.verifyEquals("订单不支持线下支付", payReqCall.getMsg(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_023() {
		Logger.start(true, "代购神器下单并支付,盛付通渠道");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createShengPayProxychain(500381009, 1);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithPayChannelType(productBean, 500381009L, 2);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6010);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_024() {
		Logger.start(true, "代购神器下单并支付,alipay渠道");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";

			payReq.setTradingId(placeOrderResp.getTradingId());
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6006");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxH5OpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6006);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("Query",
					payReqCall.getData().get("resultType"), "验证resultType");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_025() {
		Logger.start(true,
				"代购神器外币标价商品，直销订单并支付，CustomSettlementCurrencyType为1,盛付通渠道");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false, true);
			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 1, 2, 500583265L, currency);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);
			payReq.setTradingId(placeOrderResp.getTradingId());

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.124.0");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRateForTe = DGSQBaseService
					.getCurrencyConfig(currency).getExchangeRmbRateForTe();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService
					.DGSQNotifyCall(
							String.valueOf(thirdTradingId),
							totalPrice.subtract(useAccountAmount)
									.multiply(exchangeRmbRateForTe)
									.setScale(2, BigDecimal.ROUND_HALF_DOWN)
									.toString(), userId.intValue(),
							BigDecimal.ZERO.toPlainString(), 6010);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_026() {
		Logger.start(true,
				"代购神器外币标价商品，直销订单并支付，CustomSettlementCurrencyType为2,盛付通渠道, 支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false, true);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 2, 500583265L,
							productBean.getCurrency());

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(BigDecimal.ZERO);
			payReq.setOrderIds(orderIds);
			payReq.setTradingId(placeOrderResp.getTradingId());

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Logger.verifyEquals("201", payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("104", payReqCall.getBCode(), "验证bcode");
			Logger.verifyEquals("订单支付失败", payReqCall.getMsg(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_027() {
		Logger.start(true,
				"代购神器商品，直销订单并支付，CustomSettlementCurrencyType为1,盛付通渠道");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 1, 2, 500583265L,
							productBean.getCurrency());

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;
			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.124.0");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6010);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_028() {
		Logger.start(true,
				"代购神器商品，直销订单并支付，CustomSettlementCurrencyType为2,盛付通渠道");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 2, 500583265L,
							productBean.getCurrency());

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("172.17.21.73");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6010);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_029() {
		Logger.start(true,
				"代购神器外币标价商品，直销订单并支付，CustomSettlementCurrencyType为1,hipopay渠道");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false, true);
			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 1, 500583265L, currency);

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRate = DGSQBaseService.getCurrencyConfig(
					currency).getExchangeRmbRate();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService
					.DGSQNotifyCall(
							String.valueOf(thirdTradingId),
							totalPrice.subtract(useAccountAmount)
									.multiply(exchangeRmbRate)
									.setScale(2, BigDecimal.ROUND_HALF_DOWN)
									.toString(), userId.intValue(),
							BigDecimal.ZERO.toPlainString(), "CNY", currency);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_030() {
		Logger.start(true,
				"代购神器外币标价商品，直销订单并支付，CustomSettlementCurrencyType为2,hipopay渠道");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false, true);
			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 2, 500583265L, currency);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingId(placeOrderResp.getMainOrderId());
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_031() {
		Logger.start(true,
				"代购神器商品，直销订单并支付，CustomSettlementCurrencyType为1, hipopay渠道, 支付成功");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false);

			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 1, 500583265L, currency);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingId(placeOrderResp.getMainOrderId());
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId), placeOrderResp
							.getPayableAmount().subtract(useAccountAmount)
							.toString(), userId.intValue(),
					BigDecimal.ZERO.toPlainString(), currency);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_032() {
		Logger.start(true,
				"代购神器商品，直销订单并支付，CustomSettlementCurrencyType为2, hipopay渠道");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 2, 500583265L, currency);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);
			payReq.setTradingId(placeOrderResp.getMainOrderId());

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_033() {
		Logger.start(true,
				"代购神器外币标价商品，直销订单并支付，CustomSettlementCurrencyType为1, 盛付通渠道，包含税费，向下调价并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false, true);
			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2(new BigDecimal("-10.00"), productBean,
							currency, new BigDecimal("0.03"), 500583265L, 1, 2);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;
			
			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");
			payReq.setTradingId(placeOrderResp.getTradingId());

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRateForTe = DGSQBaseService
					.getCurrencyConfig(currency).getExchangeRmbRateForTe();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService
					.DGSQNotifyCall(
							String.valueOf(thirdTradingId),
							totalPrice.subtract(useAccountAmount)
									.multiply(exchangeRmbRateForTe)
									.setScale(2, BigDecimal.ROUND_HALF_DOWN)
									.toString(), userId.intValue(),
							BigDecimal.ZERO.toPlainString(), 6010);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_034() {
		Logger.start(true,
				"代购神器外币标价商品，直销订单并支付，CustomSettlementCurrencyType为1, 盛付通渠道，第三方回调前向下调价，支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false, true);
			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 1, 2, 500583265L,
							productBean.getCurrency());

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			BigDecimal freight = orderList.stream()
					.map(order -> order.getOrderPo().getFreight())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			Long userId = placeOrderResp.getUserId();
			long orderId = orderList.get(0).getOrderId();
			long sellerId = orderList.get(0).getSellerId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);
			payReq.setTradingId(placeOrderResp.getTradingId());

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 支付后，回调前设置折扣
			payReq.setDiscountAfterPay(true);

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			SqTradingCallService.changeDiscount(orderId, sellerId,
					new BigDecimal("-10"), freight);

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRateForTe = DGSQBaseService
					.getCurrencyConfig(currency).getExchangeRmbRateForTe();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService
					.DGSQNotifyCall(
							String.valueOf(thirdTradingId),
							totalPrice.subtract(useAccountAmount)
									.multiply(exchangeRmbRateForTe)
									.setScale(2, BigDecimal.ROUND_HALF_DOWN)
									.toString(), userId.intValue(),
							BigDecimal.ZERO.toPlainString(), 6010);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);
			
			Thread.sleep(3000);
			database.clearCache();

			Logger.verifyEquals(1, database.selectOrderbyOrderId(orderId)
					.getOrderStatus(), "验证orderStatus");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_045() {
		Logger.start(true, "代购神器,多商品，多货头下单并支付，hipopay支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			Integer mchId = DGSQBaseService.createIndependenceMch("USA");

			// 创建第一个供货商商品
			AgentProductBean supplierProductBean_1 = DGSQBuildProxyChainCallService
					.createSupplierProduct(mchId, "USA", "CNY", false);

			AgentProductBean agentProductBean_1 = DGSQBuildProxyChainCallService
					.importAgentProduct(mchId, supplierProductBean_1);

			agentProductBean_1 = DGSQBuildProxyChainCallService
					.createIndependenceChannel(mchId, mchId,
							agentProductBean_1.getProductId(), "CHN");
			agentProductBean_1.setGoodsOwnerId(supplierProductBean_1
					.getGoodsOwnerId());

			// 创建第二个供货商商品
			AgentProductBean supplierProductBean_2 = DGSQBuildProxyChainCallService
					.createSupplierProduct(mchId, "JPN", "CNY", false);

			AgentProductBean agentProductBean_2 = DGSQBuildProxyChainCallService
					.importAgentProduct(mchId, supplierProductBean_2);

			agentProductBean_2 = DGSQBuildProxyChainCallService
					.importAgentProduct(agentProductBean_1.getSellerId(),
							agentProductBean_2);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithTwoSuppliers(agentProductBean_1, 1,
							agentProductBean_2, 3, null, 1);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_047() {
		Logger.start(true, "代购神器,多商品，多货头下单并支付，盛付通通道，盛付通支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			Integer mchId = DGSQBaseService.createIndependenceMch("USA");

			// 创建第一个供货商商品
			AgentProductBean supplierProductBean_1 = DGSQBuildProxyChainCallService
					.createSupplierProduct(mchId, "USA", "CNY", false);

			AgentProductBean agentProductBean_1 = DGSQBuildProxyChainCallService
					.importAgentProduct(mchId, supplierProductBean_1);

			agentProductBean_1 = DGSQBuildProxyChainCallService
					.createIndependenceChannel(mchId, mchId,
							agentProductBean_1.getProductId(), "CHN");
			agentProductBean_1.setGoodsOwnerId(supplierProductBean_1
					.getGoodsOwnerId());

			// 创建第二个供货商商品
			AgentProductBean supplierProductBean_2 = DGSQBuildProxyChainCallService
					.createSupplierProduct(mchId, "JPN", "CNY", false);

			AgentProductBean agentProductBean_2 = DGSQBuildProxyChainCallService
					.importAgentProduct(mchId, supplierProductBean_2);

			agentProductBean_2 = DGSQBuildProxyChainCallService
					.importAgentProduct(agentProductBean_1.getSellerId(),
							agentProductBean_2);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithTwoSuppliers(agentProductBean_1, 1,
							agentProductBean_2, 3, null, 2);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(), 6010);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	// openid不匹配
	public void Tc_DGSQOrderPay_048() {
		Logger.start(true, "代购神器下单并支付, payType为6001");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPlatformProxychain(
							(int) platformSupplierGoodsOwnerId, 1, false, "CNY");
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, platformSupplierGoodsOwnerId);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6004");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxH5OpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_049() {
		Logger.start(true, "代购神器下单并支付, payType为6002");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6002");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxH5OpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_050() {
		Logger.start(true, "代购神器下单并支付, payType为6003");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6003");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxH5OpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_051() {
		Logger.start(true, "代购神器下单并支付, payType为6011");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);

			int userId = new OrderCallService().createNewUser();

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.buildDGSQStandPlaceOrderReq(1234, BigDecimal.ZERO, userId,
							productBean, autotest_goodsOwnerId, false);

			placeOrderReq.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0).setProductNum(1);
			placeOrderReq.setPayChannelType(2);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.callPlaceOrderService(placeOrderReq);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6011");
			payReq.setOpenId(SQPayGateWayCallService.SFTH5OpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(), userId,
					BigDecimal.ZERO.toPlainString(), 6011);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_052() {
		Logger.start(true, "代购神器外币标价商品，payChannelType为1，直销订单并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false, true);
			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, null, 1, 500583265L,
							productBean.getCurrency());

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);
			payReq.setTradingId(placeOrderResp.getTradingId());

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.124.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxH5OpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_053() {
		Logger.start(true, "代购神器外币标价商品，payChannelType为2，直销订单并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false, true);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, null, 2, 500583265L,
							productBean.getCurrency());

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;
			
			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);
			payReq.setTradingId(placeOrderResp.getTradingId());

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.124.0");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRateForTe = DGSQBaseService
					.getCurrencyConfig(productBean.getCurrency())
					.getExchangeRmbRateForTe();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService
					.DGSQNotifyCall(
							String.valueOf(thirdTradingId),
							totalPrice.subtract(useAccountAmount)
									.multiply(exchangeRmbRateForTe)
									.setScale(2, BigDecimal.ROUND_HALF_DOWN)
									.toString(), userId.intValue(),
							BigDecimal.ZERO.toPlainString(), 6010);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_054() {
		Logger.start(true,
				"代购神器外币标价商品，CustomSettlementCurrencyType为1， payChannelType为2，直销订单并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false, true);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 1, 2, 500583265L,
							productBean.getCurrency());

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);
			payReq.setTradingId(placeOrderResp.getTradingId());

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.124.0");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRateForTe = DGSQBaseService
					.getCurrencyConfig(productBean.getCurrency())
					.getExchangeRmbRateForTe();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService
					.DGSQNotifyCall(
							String.valueOf(thirdTradingId),
							totalPrice.subtract(useAccountAmount)
									.multiply(exchangeRmbRateForTe)
									.setScale(2, BigDecimal.ROUND_HALF_DOWN)
									.toString(), userId.intValue(),
							BigDecimal.ZERO.toPlainString(), 6010);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	// 特殊用例，payment表中payCurrency与支付回调的支付币种一样，应该是CNY
	public void Tc_DGSQOrderPay_055() {
		Logger.start(true, "代购神器外币标价商品，标价币种和结算币种不一致，payChannelType为1，直销订单并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500899225, 0, false, "JPY");
			String currency = productBean.getCurrency();

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, null, 1, 500899225L,
							productBean.getCurrency());

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);
			payReq.setTradingId(placeOrderResp.getTradingId());

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxH5OpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRate = DGSQBaseService.getCurrencyConfig(
					currency).getExchangeRmbRate();

			BigDecimal payAmount = SQPayGateWayCallService
					.DGSQNotifyCall(
							String.valueOf(thirdTradingId),
							totalPrice.subtract(useAccountAmount)
									.multiply(exchangeRmbRate)
									.setScale(2, BigDecimal.ROUND_HALF_DOWN)
									.toString(), userId.intValue(),
							BigDecimal.ZERO.toPlainString(), "CNY", "USD");

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_056() {
		Logger.start(true, "代购神器外币标价直销订单，支付人民币超过5w，盛付通渠道被风控");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false, true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.placeOrderOver50000(productBean, 2, 500583265L,
							productBean.getCurrency());

			TradingServiceResp placeOrderResp = SqTradingCallService
					.callPlaceOrderService(placeOrderReq);

			List<Order> orderList = placeOrderResp.getOrderList();
			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("172.17.21.73");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Logger.verifyEquals("201", payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("118", payReqCall.getBCode(), "验证bCode");
			Logger.verifyEquals("亲爱的，你的支付金额不能超过5W，请联系卖家", payReqCall.getMsg(),
					"验证msg");
			Logger.verifyEquals(118, payReqCall.getErrorCodeValue(),
					"验证errorCodeValue");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_057() {
		Logger.start(true, "代购神器外币标价直销订单，支付人民币超过5w，白名单用户，盛付通渠道不被风控");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false,
							true);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.placeOrderOver50000(productBean, 2, autotest_goodsOwnerId,
							productBean.getCurrency());

			TradingServiceResp placeOrderResp = SqTradingCallService
					.callPlaceOrderService(placeOrderReq);

			List<Order> orderList = placeOrderResp.getOrderList();
			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("172.17.21.73");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRateForTe = DGSQBaseService
					.getCurrencyConfig(productBean.getCurrency())
					.getExchangeRmbRateForTe();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService
					.DGSQNotifyCall(
							String.valueOf(thirdTradingId),
							totalPrice.subtract(useAccountAmount)
									.multiply(exchangeRmbRateForTe)
									.setScale(2, BigDecimal.ROUND_HALF_DOWN)
									.toString(), userId.intValue(),
							BigDecimal.ZERO.toPlainString(), 6010);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_058() {
		Logger.start(true, "代购神器直销订单，支付人民币超过5w，盛付通渠道被风控");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.placeOrderOver50000(productBean, 2, 500583265L,
							productBean.getCurrency());

			TradingServiceResp placeOrderResp = SqTradingCallService
					.callPlaceOrderService(placeOrderReq);

			List<Order> orderList = placeOrderResp.getOrderList();
			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("172.17.21.73");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Logger.verifyEquals("201", payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("118", payReqCall.getBCode(), "验证bCode");
			Logger.verifyEquals("亲爱的，你的支付金额不能超过5W，请联系卖家", payReqCall.getMsg(),
					"验证msg");
			Logger.verifyEquals(118, payReqCall.getErrorCodeValue(),
					"验证errorCodeValue");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_059() {
		Logger.start(true, "代购神器一个直销订单，一个代理订单，支付人民币超过5w，盛付通渠道被风控");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 1, false);

			AgentProductBean productBean2 = DGSQBuildProxyChainCallService
					.createProxychain((int) productBean.getSellerId(), 0, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.placeOrderOver50000(productBean, 2, 500583265L,
							productBean.getCurrency());

			OrderVo orderVo2 = SqTradingCallService.createOrderVo(Arrays
					.asList(productBean2));

			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo2);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.callPlaceOrderService(placeOrderReq);

			List<Order> orderList = placeOrderResp.getOrderList();
			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("172.17.21.73");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Logger.verifyEquals("201", payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("118", payReqCall.getBCode(), "验证bCode");
			Logger.verifyEquals("亲爱的，你的支付金额不能超过5W，请联系卖家", payReqCall.getMsg(),
					"验证msg");
			Logger.verifyEquals(118, payReqCall.getErrorCodeValue(),
					"验证errorCodeValue");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_060() {
		Logger.start(true, "代购神器两个直销订单，支付人民币超过5w，盛付通渠道被风控");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false);

			AgentProductBean productBean2 = DGSQBuildProxyChainCallService
					.createProxychain(500583265, 0, false);

			PlaceOrderReq placeOrderReq = SqTradingCallService
					.placeOrderOver50000(productBean, 2, 500583265L,
							productBean.getCurrency());

			OrderVo orderVo2 = SqTradingCallService.createOrderVo(Arrays
					.asList(productBean2));

			placeOrderReq.getOrderGroups().get(0).getOrders().add(orderVo2);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.callPlaceOrderService(placeOrderReq);

			List<Order> orderList = placeOrderResp.getOrderList();
			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("172.17.21.73");
			payReq.setBankId("123");
			payReq.setPayType("6010");
			payReq.setOpenId(SQPayGateWayCallService.SFTWxOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Logger.verifyEquals("201", payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("118", payReqCall.getBCode(), "验证bCode");
			Logger.verifyEquals("亲爱的，你的支付金额不能超过5W，请联系卖家", payReqCall.getMsg(),
					"验证msg");
			Logger.verifyEquals(118, payReqCall.getErrorCodeValue(),
					"验证errorCodeValue");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	// 支付金额与实际提交给网关的支付金额不一致，需要多试几次
	public void Tc_DGSQOrderPay_061() {
		Logger.start(true, "代购神器人民币标价商品，商户不允许收人民币，payChannelType为1，直销订单并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500956988, 0, false);
			String currency = "USD";

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, 500956988L);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);
			payReq.setTradingId(placeOrderResp.getTradingId());

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.124.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxH5OpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRate = DGSQBaseService.getCurrencyConfig(
					"USD").getExchangeRmbRate();

			totalPrice = totalPrice.multiply(
					BigDecimal.ONE.divide(exchangeRmbRate, 7,
							BigDecimal.ROUND_HALF_DOWN)).setScale(2,
					BigDecimal.ROUND_HALF_DOWN);

			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency, currency);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_062() {
		Logger.start(true, "代购神器人民币标价商品，商户不允许收人民币，一个支付单多个订单，直销订单并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain(500956988, 0, false);
			String currency = "USD";

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2(BigDecimal.ZERO, productBean, null,
							BigDecimal.ZERO, (long) 500956988, 1);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);
			payReq.setTradingId(placeOrderResp.getTradingId());

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.124.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxH5OpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 根据人民币离岸汇率计算
			BigDecimal exchangeRmbRate = DGSQBaseService.getCurrencyConfig(
					"USD").getExchangeRmbRate();

			totalPrice = totalPrice.multiply(
					BigDecimal.ONE.divide(exchangeRmbRate, 7,
							BigDecimal.ROUND_HALF_DOWN)).setScale(2,
					BigDecimal.ROUND_HALF_DOWN);

			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency, currency);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_063() {
		Logger.start(true, "代购神器下单，带有服务费率，货币为USD，买家同意线下支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false,
							true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithServiceRate(productBean, true, currency);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("200");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");
			payReq.setVoucherUrl(TestDataManager.randomStr(8));

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(totalPrice.subtract(BigDecimal.ZERO));

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_064() {
		Logger.start(true, "代购神器下单，线下支付订单不输入支付凭证，支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, BigDecimal.ZERO,
							autotest_goodsOwnerId, currency, true);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("200");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("h5sqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Logger.verifyEquals("400", payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("100", payReqCall.getBCode(), "验证bCode");
			Logger.verifyEquals("支付凭证未提供", payReqCall.getMsg(), "验证msg");
			Logger.verifyEquals(100, payReqCall.getErrorCodeValue(),
					"验证errorCodeValue");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_067() {
		Logger.start(true, "代购神器下单，抖音支付宝支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6207");
			payReq.setOpenId(SQPayGateWayCallService.TouTiaoOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("500041475");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_068() {
		Logger.start(true, "代购神器下单，yaband支付，货币为CNY");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) yabandGoodsOwnerId, 0, false);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeYabandOrder(productBean, yabandGoodsOwnerId, currency);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			SqTradingCallService
					.changeDiscount(
							placeOrderResp.getOrderList().get(0).getOrderId(),
							placeOrderResp.getOrderList().get(0).getSellerId(),
							placeOrderResp
									.getPayableAmount()
									.subtract(new BigDecimal("1.00"))
									.negate()
									.add(placeOrderResp.getOrderList().get(0)
											.getOrderDetailPoList().get(0)
											.getFreight()), BigDecimal.ZERO);

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6301");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_069() {
		Logger.start(true, "代购神器下单，yaband支付，货币为EUR");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) yabandGoodsOwnerId, 0, false, true);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeYabandOrder(productBean, yabandGoodsOwnerId, currency);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			SqTradingCallService.changeDiscount(placeOrderResp
					.getOrderList().get(0).getOrderId(), placeOrderResp
					.getOrderList().get(0).getSellerId(), placeOrderResp
					.getPayableAmount().subtract(new BigDecimal("0.1"))
					.negate(), placeOrderResp.getOrderList().get(0)
					.getOrderDetailPoList().get(0).getFreight());

			Logger.comment("前置数据准备结束");

			// BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6301");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_070() {
		Logger.start(true, "一天付款笔数超过分控限额，无风控，yaband支付，支付成功");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) yabandGoodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeYabandOrder(productBean, yabandGoodsOwnerId,
							productBean.getCurrency());

			CounterService.setUserPaidCounter(15, "hpAccount_20238");

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(BigDecimal.ZERO);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6301");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_071() {
		Logger.start(true, "代购神器下单，连锁店模式，货币为CNY");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) chainStoreGoodsOwnerId, 0, false);
			String currency = productBean.getCurrency();
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeChainStoreOrder(productBean, chainStoreGoodsOwnerId, currency);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;
			
			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6401");
			payReq.setOpenId(SQPayGateWayCallService.WxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("501476063");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(BigDecimal.ZERO).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString(),
					currency, 6401);

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_072() {
		Logger.start(true, "一天付款笔数超过分控限额，无风控，连锁店，支付成功");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) chainStoreGoodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeChainStoreOrder(productBean, chainStoreGoodsOwnerId,
							productBean.getCurrency());

			CounterService.setUserPaidCounter(15, "hpAccount_20238");

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(BigDecimal.ZERO);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6401");
			payReq.setOpenId(SQPayGateWayCallService.WxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("501476063");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_073() {
		Logger.start(true, "代购神器下单并支付，第三方回调前向下调价，支付失败，快速退款");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			BigDecimal freight = orderList.stream()
					.map(order -> order.getOrderPo().getFreight())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			Long userId = placeOrderResp.getUserId();
			long orderId = orderList.get(0).getOrderId();
			long sellerId = orderList.get(0).getSellerId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			SqTradingCallService.changeDiscount(orderId, sellerId,
					BigDecimal.TEN.negate(), freight);

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);
			database.clearCache();

			Logger.verifyEquals(1, database.selectOrderbyOrderId(orderId)
					.getOrderStatus(), "验证orderStatus");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_074() {
		Logger.start(true, "代购神器下单，代币支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createIndependenceProxychain((int)virtualCoinGoodsOwnerId, 1, false, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithUserIdAndGoodsOwnerIdAndCurrency(
							productBean, productBean.getSellerId(),
							virtualCoinGoodsOwnerId, productBean.getCurrency());
			
			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();
			
			// 充值代币
			SqPretradeService.virtualCoinCharge(virtualCoinGoodsOwnerId,
					productBean.getSellerId(), useAccountAmount);

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("7000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_075() {
		Logger.start(true, "代购神器下单，外币标价，使用代币支付，支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createIndependenceProxychain((int)virtualCoinGoodsOwnerId, 1, false, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithUserIdAndGoodsOwnerIdAndCurrency(
							productBean, productBean.getSellerId(),
							virtualCoinGoodsOwnerId, productBean.getCurrency());
			
			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();
			
			// 充值代币
			SqPretradeService.virtualCoinCharge(virtualCoinGoodsOwnerId,
					productBean.getSellerId(), useAccountAmount);

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("7000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Logger.verifyEquals("201", payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("105", payReqCall.getBCode(), "验证bCode");
			Logger.verifyEquals("外币订单不可使用代币余额支付", payReqCall.getMsg(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_076() {
		Logger.start(true, "代购神器下单，使用代币支付，余额不足，支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createIndependenceProxychain((int)virtualCoinGoodsOwnerId, 1, false, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithUserIdAndGoodsOwnerIdAndCurrency(
							productBean, productBean.getSellerId(),
							virtualCoinGoodsOwnerId, productBean.getCurrency());
			
			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();
			
			// 充值代币
			SqPretradeService.virtualCoinCharge(virtualCoinGoodsOwnerId,
					productBean.getSellerId(), useAccountAmount.subtract(new BigDecimal("0.01")));

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("7000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Logger.verifyEquals("201", payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("105", payReqCall.getBCode(), "验证bCode");
			Logger.verifyEquals("账户金额不足", payReqCall.getMsg(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_077() {
		Logger.start(true, "代购神器下单，多货头，使用代币支付，支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			
			AgentProductBean supplier_1 = DGSQBuildProxyChainCallService
					.createIndependenceProxychain((int) virtualCoinGoodsOwnerId, 1, false, false);
			
			AgentProductBean supplier_2 = DGSQBuildProxyChainCallService
					.createIndependenceProxychain((int) supplier_1.getSellerId(), 0, false, false);
			
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithTwoSuppliersAndUserId(supplier_1, 1,
							supplier_2, 1, null, null, supplier_1.getSellerId());
			
			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();
			
			// 充值代币
			SqPretradeService.virtualCoinCharge(virtualCoinGoodsOwnerId,
					supplier_1.getSellerId(), useAccountAmount);

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("7000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Logger.verifyEquals("201", payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("105", payReqCall.getBCode(), "验证bCode");
			Logger.verifyEquals("订单不可使用代币余额支付", payReqCall.getMsg(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_078() {
		Logger.start(true, "代购神器下单，一个支付单多个订单，使用代币支付，直销订单并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createIndependenceProxychain((int)virtualCoinGoodsOwnerId, 1, false, false);

			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder2WithUserId(BigDecimal.ZERO, productBean, null,
							BigDecimal.ZERO, (long) virtualCoinGoodsOwnerId, 1, productBean.getSellerId());

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = placeOrderResp.getPayableAmount();
			
			// 充值代币
			SqPretradeService.virtualCoinCharge(virtualCoinGoodsOwnerId,
					productBean.getSellerId(), useAccountAmount);

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("7000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_079() {
		Logger.start(true, "代购神器下单并代付，订单需要身份证，支付未输入身份证");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderNeedIdCard(productBean, autotest_goodsOwnerId);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");
			
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");
			payReq.setHelpPayUserId(1234L);

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();
			
			Thread.sleep(3000);

			Logger.verifyEquals("400", payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("代付时，缺少代付人信息", payReqCall.getData().get("errorMessage"),
					"验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_080() {
		Logger.start(true, "代购神器下单，他人代付订单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 1, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderNeedIdCard(productBean, autotest_goodsOwnerId);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");
			payReq.setHelpPayUserId(9000L);
			payReq.setHelpPayIdcardId(1000L);

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_081() {
		Logger.start(true, "代购神器定金订单下单并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingBookingOrderCallService
					.placeBookingOrder(productBean);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			
			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(BigDecimal.ZERO);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");
			payReq.setTradeType(2);

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_082() {
		Logger.start(true, "代购神器定金订单已支付，再次支付，支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingBookingOrderCallService
					.placeBookingOrder(productBean);
			
			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			
			// 支付定金订单
			Long thirdTradingId = SqTradingBookingOrderCallService
					.payBookingOrder(userId, placeOrderResp.getTradingId());

			// 支付网关支付回调交易
			SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId), totalPrice.toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());
			
			Thread.sleep(5000);

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(BigDecimal.ZERO);
			payReq.setOrderIds(orderIds);
			payReq.setTradingId(placeOrderResp.getTradingId());

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");
			payReq.setTradeType(2);

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Logger.verifyEquals(ECode.FAILED201, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("定金订单未二次确认不能进行全款支付",
					payReqCall.getData().get("errorMessage"), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_083() {
		Logger.start(true, "代购神器定金订单全款支付，支付成功");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false);
			TradingServiceResp placeOrderResp = SqTradingBookingOrderCallService
					.placeSecondConfirmOrder(productBean);
			
			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			
			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(BigDecimal.ZERO);
			payReq.setOrderIds(orderIds);
			payReq.setTradingId(placeOrderResp.getTradingId());

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");
			payReq.setTradeType(1);

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();
			
			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_084() {
		Logger.start(true, "中免澳门大会员，使用积分下单并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) macaoCDFGoodsOwnerId, 0, false, true);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeCDFMacaoOrderIntegral(productBean, 10L);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);
			
			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("7200");
//			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.CDFMacaoWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("502665591");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			SqTradingCallService.orderPayCallBack(thirdTradingId, userId,
					totalPrice);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	// 还未上产线
	public void Tc_DGSQOrderPay_085() {
		Logger.start(true, "中免下单，招行支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createProxychain((int) autotest_goodsOwnerId, 0, false, false);
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrderWithCMBPayAndCrossBoderType(productBean, 1);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);
			
			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("8000");
			payReq.setOpenId(SQPayGateWayCallService.CDFCMBWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("510019073");
			
			payReq.setPayAmount(totalPrice);

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			SqTradingCallService.orderPayCMBCallBack(thirdTradingId, userId,
					totalPrice);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_086() {
		Logger.start(true, "代购神器平台供货商下单并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPlatformProxychain(
							(int) platformSupplierGoodsOwnerId, 1, false, "CNY");
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, platformSupplierGoodsOwnerId);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_087() {
		Logger.start(true, "代购神器平台供货商下单，paytype为6006，支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPlatformProxychain(
							(int) platformSupplierGoodsOwnerId, 1, false, "CNY");
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placeOrder(productBean, platformSupplierGoodsOwnerId);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6207");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Logger.verifyEquals("201", payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("105", payReqCall.getBCode(), "验证bcode");
			Logger.verifyEquals("平台供货商订单支付类型错误", payReqCall.getMsg(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_088() {
		Logger.start(true, "代购神器平台供货商+普通订单下单并支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPlatformProxychain(
							(int) platformSupplierGoodsOwnerId, 1, false, "CNY");
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placePlatformSupplierMixedOrder(productBean, platformSupplierGoodsOwnerId);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();
			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(useAccountAmount).toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(Now.class)
	@TestCase
	public void Tc_DGSQOrderPay_089() {
		Logger.start(true, "代购神器平台供货商+普通订单下单并支付, paytype为6401，支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createPlatformProxychain(
							(int) platformSupplierGoodsOwnerId, 1, false, "CNY");
			TradingServiceResp placeOrderResp = SqTradingCallService
					.placePlatformSupplierMixedOrder(productBean, platformSupplierGoodsOwnerId);

			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Long userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			BigDecimal useAccountAmount = BigDecimal.ZERO;

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(useAccountAmount);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6401");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");
			
			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Logger.verifyEquals("201", payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("105", payReqCall.getBCode(), "验证bcode");
			Logger.verifyEquals("平台供货商订单支付类型错误", payReqCall.getMsg(), "验证msg");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_090() {
		Logger.start(true, "代购神器预售库存下单并支付定金，添加库存并核销");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createMultiCodeProxychainForPreSale(
							(int) multiCDFCodeGoodsOwnerId, false);

			TradingServiceResp placeOrderResp = SqTradingBookingOrderCallService.placePreSaleActivityBookingOrder(
					productBean, 10);

			Long userId = placeOrderResp.getUserId();
			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(BigDecimal.ZERO);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");
			payReq.setTradeType(2);

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			// 添加实际库存
			SqStockService.OpenAdjustStock(multiCDFCodeGoodsOwnerId,
					placeOrderResp.getOrderList().get(0).getOrderDetailPoList().get(0).getProductId(),
					placeOrderResp.getOrderList().get(0).getOrderDetailPoList().get(0).getCatalogId());

			Thread.sleep(60000);

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO, true);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(Now.class)
	@TestCase
	@Ignore
	public void Tc_DGSQOrderPay_091() {
		Logger.start(true, "代购神器预售库存下单并全款支付，添加库存并核销");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			AgentProductBean productBean = DGSQBuildProxyChainCallService
					.createMultiCodeProxychainForPreSale(
							(int) multiCDFCodeGoodsOwnerId, false);

			TradingServiceResp placeOrderResp = SqTradingBookingOrderCallService.placePreSaleActivitySecondConfirmOrder(
					productBean);

			Long userId = placeOrderResp.getUserId();
			List<Order> orderList = placeOrderResp.getOrderList();

			List<Long> orderIds = new ArrayList<Long>();

			orderList.forEach(o -> orderIds.add(o.getOrderId()));

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayableAmount();

			// 参数
			payReq.setCallbackUrl("www.ymtautotest.com");
			payReq.setUserId(userId);
			payReq.setUseAccountAmount(BigDecimal.ZERO);
			payReq.setOrderIds(orderIds);

			String tradingPassword = "abc123";
			payReq.setTradingPwd(tradingPassword);
			payReq.setUserIp("103.84.20.0");
			payReq.setBankId("123");
			payReq.setPayType("6000");
			payReq.setOpenId(SQPayGateWayCallService.HipoPayWxAppOpenId);
			payReq.setParamExt("");
			payReq.setMemo("备注");
			payReq.setShenqiMpId("wxsqBuyer");
			payReq.setTradeType(1);

			// 发送请求
			payReqCall.setData(payReq);
			payReqCall.callService();

			Long thirdTradingId = payReqCall.getTradingId();

			// 支付网关支付回调交易
			BigDecimal payAmount = SQPayGateWayCallService.DGSQNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.toString(),
					userId.intValue(), BigDecimal.ZERO.toPlainString());

			// 设置支付网关实际支付的rmb金额
			payReq.setPayAmount(payAmount);

			Thread.sleep(3000);

			Logger.verifyEquals(ECode.SUCCESS, payReqCall.getCode(), "验证Code");
			Logger.verifyEquals("JSON", payReqCall.getData().get("resultType"),
					"验证Code");

			// 添加实际库存
			SqStockService.OpenAdjustStock(multiCDFCodeGoodsOwnerId,
					placeOrderResp.getOrderList().get(0).getOrderDetailPoList().get(0).getProductId(),
					placeOrderResp.getOrderList().get(0).getOrderDetailPoList().get(0).getCatalogId());

			Thread.sleep(60000);

			verifyDb(payReqCall.getTradingId(), payReq.getUseAccountAmount(),
					orderList, BigDecimal.ZERO, true);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	public static void main(String[] args) {
		
		// BigDecimal[] orderDetailSubWeights = {new BigDecimal("600"), new
		// BigDecimal("144")};
		//
		// BigDecimal[] orderDetailSubDiscount = Utils
		// .apportionByWeights3(
		// new BigDecimal("9.00"),
		// orderDetailSubWeights);
		// System.out.println("123");

		// System.out.println(new BigDecimal("2175.00").divide(new BigDecimal(
		// "2185.00"), 2, BigDecimal.ROUND_DOWN));
		//
		// System.out.println(new BigDecimal("2175.00")
		// .divide(new BigDecimal("2185.00"), 10, BigDecimal.ROUND_DOWN)
		// .multiply(new BigDecimal("1868.17"))
		// .setScale(2, BigDecimal.ROUND_DOWN));
	}
}
